/**
 * 报表设计公司(2011)
 */
package com.reportgear.designer.action.file;

import java.awt.event.ActionEvent;

import netscape.javascript.JSObject;

import com.reportgear.core.util.ImageUtils;
import com.reportgear.designer.action.ReportAction;
import com.reportgear.report.model.ReportModel;
import com.reportgear.report.setting.AppletSettings;

/**
 * 打开报表
 * 
 * @version 1.0 2011-3-24
 * @author <a herf="lexloo@gmail.com">lexloo</a>
 * @since ANNCSR 2.0
 */
public class OpenReportAction extends ReportAction {

	public OpenReportAction() {
		setName("打开报表");
		setSmallIcon(ImageUtils.readIcon("/resources/images/file/open.png"));
	}

	public void actionPerformed(ActionEvent e) {
		ReportModel rm = this.getWorkSheet().getReportModel();
		JSObject jso = AppletSettings.INSTANCE.getJsObject();
		if (jso != null) {
			String xml = (String) jso.call("GetTemplateById", new String[] { "1" });
			rm.fromXmlString(xml);

			this.getWorkSheet().refresh();
		}

		// rm.readXml("c:\\test.xml");
		//
		// this.getWorkSheet().refresh();

		// ReportModel model = this.getWorkSheet().getReportModel();
		//
		// model.addDataModel(new SalaryDataModel());
		//
		// new ParameterCalculator().calculate(model, false);
		// new FormulaCalculator().calculate(model, false);
		// new CrossDataObjectCalculator().calculate(model, false);
		// new CrossDataObjectValueCalculator().calculate(model, false);
		//
		// this.getWorkSheet().refresh();
	}
}
